/*
********************************************************************************
* Copyright (C) 2021, xiang.D <dx_65535@163.com>.
* All right reserved.
*
* File Name   : main.cc
* Author      :
* Version     : V1.0
* Description :
* Journal     : 2021-1-27 version v1.0
* Brief       : Blog: https://blog.csdn.net/qq_38750572?spm=1001.2014.3001.5343
* Others      :
                Compile command: make
********************************************************************************
*/

#include <stdio.h>
#include "app_view.h"

#define MAIN_LOGI(fmt, args...) printf(fmt, ##args)
#define MAIN_LOGD(fmt, args...) printf("%d Main D: " fmt, __LINE__, ##args)
#define MAIN_LOGW(fmt, args...) printf("%d Main W: " fmt, __LINE__, ##args)
#define MAIN_LOGE(fmt, args...) printf("%d Main E: " fmt, __LINE__, ##args)
#define MAIN_LOG(fmt, args...)  printf(fmt, ##args)

CTimView theTim(10, 20, 8, 30);         // Width: 10 - 20, Heigh: 20 - 30
CChromeView theChrome(25, 30, 40, 50);  // Width: 25 - 30, Heigh: 40 - 50
CWeChatView theWeChat(40, 50, 60, 80);  // Width: 40 - 50, Heigh: 60 - 80

static void init()
{
    // 设置责任链顺序: theTim -> theChrome -> theWeChat
    theChrome.SetNextHandler(&theWeChat);
    theTim.SetNextHandler(&theChrome);
}

int main(int argc, char *argv[])
{
    init();

    // TODO: 创建一个Event管理器，处理并分发点击事件
    SClickLocation clickEvent1 = {28, 42};   // 点击坐标(28, 42), Chrome
    theTim.HandleRequest(&clickEvent1);

    SClickLocation clickEvent2 = {48, 62};   // 点击坐标(48, 62), WeChat
    theTim.HandleRequest(&clickEvent2);

    SClickLocation clickEvent3 = {12, 20};   // 点击坐标(12, 20), Tim
    theTim.HandleRequest(&clickEvent3);

    return 0;
}